package day014.homework.p5;

import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        list.add(new Student("张三", 24, "男"));
        list.add(new Student("李四", 25, "男"));
        list.add(new Student("麻子", 23, "男"));

        int maxAge = 0;
        for (Student s : list) {
            maxAge = Math.max(maxAge, s.getAge());
        }

        for (Student s : list) {
            if (s.getAge() == maxAge) {
                s.setName("小猪佩奇");
            }
            System.out.println(s);
        }
    }
}
